#!/usr/bin/env python

import wx
import resource.toolbar as toolbar

class ToolBar(wx.ToolBar):
    '''ToolBar class
    
    @author Julot <andy.julot@gmail.com>
    @since Sunday, January 29, 2012. 12:52 PM'''
    
    def __init__(self, parent):
        style = wx.TB_HORIZONTAL | wx.TB_FLAT
        super(ToolBar, self).__init__(parent, style=style)
        self.SetToolBitmapSize((16, 16))
        
        s = 'Print CD Back Cover.'
        tool = self.AddTool(-1,
                            bitmap=toolbar.Printer.Bitmap,
                            shortHelpString='Print',
                            longHelpString=s)
        self.mold = tool
        
        s = 'Print Preview CD Back Cover.'
        tool = self.AddTool(-1,
                            bitmap=toolbar.DocumentSearchResult.Bitmap,
                            shortHelpString='Print Preview',
                            longHelpString=s)
        self.printPreview = tool
        
        self.disablePrint()
        
        self.AddSeparator()
        
        s = 'Download AniDb XML file.'
        tool = self.AddTool(-1,
                            bitmap=toolbar.DocumentXaml.Bitmap,
                            shortHelpString='Download XML',
                            longHelpString=s)
        self.downloadXml = tool
        self.disableDownloadXml()
        
        s = 'Download AniDb image file.'
        tool = self.AddTool(-1,
                            bitmap=toolbar.ImageVertical.Bitmap,
                            shortHelpString='Download Image',
                            longHelpString=s)
        self.downloadImage = tool
        self.disableDownloadImage()

        self.AddSeparator()
        
        tool = self.AddTool(-1,
                            bitmap=toolbar.QuestionButton.Bitmap,
                            shortHelpString='Help',
                            longHelpString='Help')
        self.aid = tool
        
        tool = self.AddTool(-1,
                            bitmap=toolbar.About.Bitmap,
                            shortHelpString='About',
                            longHelpString='About')
        self.about = tool
        
        self.AddSeparator()
        
        s = 'Close the application'
        tool = self.AddTool(-1,
                            bitmap=toolbar.DoorOpenOut.Bitmap,
                            shortHelpString='Quit',
                            longHelpString=s)
        self.close = tool
        
    def enablePrint(self):
        self.EnableTool(self.mold.Id, True)
        self.EnableTool(self.printPreview.Id, True)
    
    def disablePrint(self):
        self.EnableTool(self.mold.Id, False)
        self.EnableTool(self.printPreview.Id, False)
    
    def enableDownloadXml(self):
        self.EnableTool(self.downloadXml.Id, True)
    
    def disableDownloadXml(self):
        self.EnableTool(self.downloadXml.Id, False)
    
    def enableDownloadImage(self):
        self.EnableTool(self.downloadImage.Id, True)
    
    def disableDownloadImage(self):
        self.EnableTool(self.downloadImage.Id, False)
    